home *** CD-ROM | disk | FTP | other *** search
- /************************************
- Program name: OQD.c
- Function: Demos Old QuickDraw Color Tricks.
- ************************************/
-
- #include "OQD_Test.h"
-
- #define TRUE 1
- #define FALSE 0
- #define NIL 0
-
- /* initial color selection */
- int colorSelection[4] = { whiteColor, blackColor, whiteColor, blackColor};
-
- /* external functions */
- extern void InitMyMenus(void);
- extern void HandleMenu(char *doneFlag, short theMenu, short theItem);
-
- void main(void);
-
- void main()
- {
- char doneFlag, ch;
- short code, theMenu, theItem, chCode;
- long mResult;
- WindowPtr whichWindow;
- EventRecord myEvent;
- Rect tempRect;
- GrafPtr SavePort;
-
- /* initialize everything */
- InitGraf(&thePort);
- InitFonts();
- FlushEvents(everyEvent,0);
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(NIL);
- InitCursor();
-
- /* initialize my own stuff */
- doneFlag = FALSE;
- InitMyMenus();
- Init_OQD_Test();
- Open_OQD_Test();
-
- do {
- SystemTask();
-
- if (GetNextEvent(everyEvent, &myEvent)) {
- code = FindWindow(myEvent.where, &whichWindow);
-
- switch (myEvent.what) {
- case mouseDown:
- if (code == inMenuBar) {
- mResult = MenuSelect(myEvent.where);
- theMenu = HiWord(mResult);
- theItem = LoWord(mResult);
- HandleMenu(&doneFlag,theMenu,theItem);
- }
-
- if ((code == inDrag)&&(whichWindow != NIL)) {
- tempRect = screenBits.bounds;
- SetRect(&tempRect, tempRect.left + 10, tempRect.top + 25, tempRect.right - 10, tempRect.bottom - 10);
- DragWindow(whichWindow, myEvent.where, &tempRect);
- }
-
- if (code == inContent) {
- if (whichWindow != FrontWindow()) {
- SelectWindow(whichWindow);
- }
- else {
- SetPort(whichWindow);
- Do_OQD_Test (&myEvent);
- }
- }
-
- if (code == inSysWindow) {
- SystemClick(&myEvent, whichWindow);
- }
-
- break;
-
- case keyDown:
- case autoKey:
- ch = myEvent.message & charCodeMask;
- if (myEvent.modifiers & cmdKey) {
- mResult = MenuKey(ch);
- theMenu = HiWord(mResult);
- theItem = LoWord(mResult);
- if (theMenu != 0)
- HandleMenu(&doneFlag, theMenu, theItem);
- }
- break;
-
- case updateEvt:
- whichWindow = (WindowPtr)myEvent.message;
- GetPort(&SavePort);
- BeginUpdate(whichWindow);
- SetPort(whichWindow);
- UpDate_OQD_Test(whichWindow);
- EndUpdate(whichWindow);
- SetPort(SavePort);
- break;
-
- case activateEvt:
- if ((whichWindow != NIL) && (myEvent.modifiers & activeFlag)) {
- SelectWindow(whichWindow);
- }
- break;
- }
-
- }
- } while (doneFlag == FALSE);
- }
-